<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- 高级查询区域 -->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="text"  alt="" style="max-width:120px;font-size: 12px;font-style: italic;"/>
        </template>

        <span slot="action" slot-scope="text, record">
           <a @click="handleDetail(record)">详情</a>

          <a-divider type="vertical" />
           <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
        </span>
      </a-table>
    </div>

    <live-modal ref="modalForm" @ok="modalFormOk"></live-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import LiveModal from './modules/LiveModal'

  export default {
    name: 'LiveList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      LiveModal
    },
    data () {
      return {
        description: '直播表管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'视频封面',
            align:"center",
            dataIndex: 'cover',
            scopedSlots: { customRender: 'imgSlot' },
          },
          {
            title:'名称',
            align:"center",
            dataIndex: 'title'
          },
          {
            title:'来自直播',
            align:"center",
            dataIndex: 'title'
          },
          {
            title:'生成时间',
            align:"center",
            dataIndex: 'createTime'
          },

          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/satff/live/list",
          delete: "/satff/live/delete",
          deleteBatch: "/satff/live/deleteBatch",
          exportXlsUrl: "/satff/live/exportXls",
          importExcelUrl: "satff/live/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'title',text:'直播标题',dictCode:''})
        fieldList.push({type:'datetime',value:'beginTime',text:'开始时间'})
        fieldList.push({type:'datetime',value:'endTime',text:'结束时间'})
        fieldList.push({type:'datetime',value:'duration',text:'直播时间'})
        fieldList.push({type:'string',value:'groupId',text:'联播群',dictCode:''})
        fieldList.push({type:'string',value:'status',text:'直播状态',dictCode:''})
        fieldList.push({type:'int',value:'viewNum',text:'观看人数',dictCode:''})
        fieldList.push({type:'string',value:'isSharePage',text:'是共享屏幕',dictCode:''})
        fieldList.push({type:'string',value:'viewPermisson',text:'直播设置',dictCode:''})
        fieldList.push({type:'int',value:'isAllowConnect',text:'是否允许连线',dictCode:''})
        fieldList.push({type:'string',value:'isOpenRecord',text:'开启直播回放',dictCode:''})
        fieldList.push({type:'string',value:'cover',text:'预览图片',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>